<template>
	<view class="">
		<u-row  customStyle="background-color: #FFFFFF;padding:16rpx 0">
			<u-col span="1"  >
				 
			 
			</u-col>
			<u-col span="7" offset="0">
			  <u--input
			     placeholder="请输入内容"
				 prefixIcon="search"
			     border="surround"
			     v-model="value"
			     
				 shape="circle"
			   ></u--input>
				<!-- <u-search placeholder="搜索内容"  @custom='search' @search='search'  bgColor='#dedede' :actionStyle='actionStyle' v-model="keyword"></u-search> -->
			</u-col>
			<u-col span="2" offset="1">
				<u-button type="primary" size="small" shape="circle" text="搜索" @click="search(value)"></u-button>
			</u-col>
		</u-row>
		<u-row  customStyle="margin-top: 30rpx;">
			<u-col span="3" >
				<u--text customStyle="margin-left: 40rpx;"   text='历史记录' size='17'> </u--text>
			</u-col>
			<u-col span="1" offset="6" @click="cleanHistory">
				<u-icon name="trash-fill" size="20"></u-icon>

			</u-col>
		</u-row>
		<view class="history">
			<text class="historyItem" v-for="(item,index) in history" @click="search(item)">{{item}}</text>
		</view>
		<u-list
					@scrolltolower="scrolltolower"
				>
					<u-list-item
						v-for="(item, index) in indexList"
						:key="index"
					>
					<u-row>
						<u-col span="3">
							{{item.goods_name}}
						</u-col>
					</u-row>
					</u-list-item>
				</u-list>
	</view>
</template>

<script>
	var that
	export default {
		data() {
			return {
				actionStyle:{
					border: '2rpx solid',
					
				},
				indexList:[],
				value:'',
				history:[],
			};
		},
		onLoad() {
			that =this
		},
		mounted() {
			let history = uni.getStorageSync('history')
			if(history){
				that.history = history
			}
		},
		methods: {
			cleanHistory(){
				that.history=[]
				uni.clearStorageSync('history')
			},
			search(a){
				console.log(a)
				if(that.history.indexOf(that.value) == -1){
					that.history.push(that.value)
				}
				uni.setStorageSync('history',that.history)
				uni.setStorageSync('search',that.history)
				uni.navigateTo({
					url:'./serachList?name='+that.value
				})
				console.log(11)
			},
			change(e){
				console.log(e)
				// this.mNetTool.getAjaxUrlValueBackground('capi/V2/ERGoodsManage/erGoodsManage/list',{goods_name:e},res =>{
				// 	console.log(res)
				// 	that.indexList = res.rows
				  
				// })
		},
		
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #e5e5e5;
		
	}
	.history {
		padding: 0 32rpx;
		&Item {
			color: #606366;
			margin: 0 15rpx;
			font-size: 26rpx;
		}
	}
	.container {
		padding: 0 32rpx;
	}
</style>
